package com.leetcode.two_pointers;

/**
 * @author Dennis Li
 * @date 2020/7/18 15:50
 */
public class JudgeSquareSum_633 {
    public boolean judgeSquareSum(int c) {
        int i = 1, j = (int) Math.pow(c, 0.5);
        if (j * j == c) return true;
        int temp = c >> 1;
        while (i <= j) {
            if (i * j > temp) {
                j--;
                i = i > 1 ? i - 1 : 1;
            } else if (i * i + j * j == c) {
                return true;
            } else i++;
        }
        return false;
    }
}
